package com.frank.activedatabus;

import com.frank.activedatabus.Core.Config;
import com.frank.activedatabus.Core.LiveEventBusCore;
import com.frank.activedatabus.Core.Observable;

public final class ActiveDataBus {


    /**
     * get observable by key with type
     *
     * @param key
     * @param type
     * @param <T>
     * @return Observable<T>
     */
    public static <T> Observable<T> get(String key, Class<T> type) {
        return LiveEventBusCore.get().getChannel(key, type);
    }

    /**
     * get observable by key
     *
     * @param key
     * @return Observable<Object>
     */
    public static Observable<Object> get(String key) {
        return get(key, Object.class);
    }


    /**
     * use the inner class Config to set params
     * first of all, call config to get the Config instance
     * then, call the method of Config to config LiveEventBus
     * call this method in Application.onCreate
     */
    public static Config config() {
        return LiveEventBusCore.get().config();
    }

}
